package com.itcast.donkey.fragments;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.itcast.donkey.R;
import com.itcast.donkey.adapters.SeachDomesticAdapter;
import com.itcast.donkey.adapters.SeachSeasonsAdapter;

/**
 * Created by lanouhn on 16/8/26.
 */
public class SeasonsFragment extends Fragment {
    private RecyclerView recyclerView;
    private SeachSeasonsAdapter adapter;

    private String[] monthName = {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"};

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_seasons, null);
        return view;
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        recyclerView = (RecyclerView) getView().findViewById(R.id.recyclerView_seasons);

        GridLayoutManager gm = new GridLayoutManager(getActivity(), 3);
        gm.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(gm);

        adapter = new SeachSeasonsAdapter(getActivity(), monthName);
        recyclerView.setAdapter(adapter);

//        // 初始化，只需要调用一次
//        AssetsDatabaseManager.initManager(getActivity().getApplication());
//        // 获取管理对象，因为数据库需要通过管理对象才能够获取
//        AssetsDatabaseManager mg = AssetsDatabaseManager.getManager();
//        // 通过管理对象获取数据库
//        SQLiteDatabase db1 = mg.getDatabase("db1.db");
//        // 对数据库进行操作
//        db1.execSQL("insert into tb([ID],[content]) values(null, 'db1');");
    }
}
